/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.citylifeprot.Screens;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.graphics.g2d.TextureAtlas;
import com.badlogic.gdx.scenes.scene2d.Stage;
import com.badlogic.gdx.scenes.scene2d.ui.Skin;
import com.citylifeprot.game.CityLifeProt;


/**
 *
 * @author Cypher
 */
public class AbstractScreen implements Screen {

    protected static final int GAME_VIEWPORT_WIDTH = 800, GAME_VIEWPORT_HEIGHT = 480;
    protected static final int MENU_VIEWPORT_WIDTH = 800, MENU_VIEWPORT_HEIGHT = 480;

    protected final CityLifeProt game;
    private BitmapFont font;
    private SpriteBatch batch;
    protected final Stage stage;
    private Skin skin;

    public CityLifeProt getGame() {
        return game;
    }
    
    public Skin getSkin(){
        if( skin == null ) {
            TextureAtlas atlas = new TextureAtlas("data/uiskin.atlas");
            skin = new Skin( Gdx.files.internal( "data/uiskin.json" ), atlas );
            
            
        }
        return skin;
    }
    

    public BitmapFont getFont() {
        return font;
    }

    public void setFont(BitmapFont font) {
        this.font = font;
    }

    public SpriteBatch getBatch() {
        return batch;
    }

    public void setBatch(SpriteBatch batch) {
        this.batch = batch;
    }

    public AbstractScreen(CityLifeProt game) {
        this.game = game;
        this.font = new BitmapFont();
        this.batch = new SpriteBatch();
        
        int width = isGameScreen() ? GAME_VIEWPORT_WIDTH : MENU_VIEWPORT_WIDTH;
        int height= isGameScreen() ? GAME_VIEWPORT_HEIGHT : MENU_VIEWPORT_HEIGHT;
        //this.stage = new Stage(width,height,true);
        this.stage = new Stage();
        //this.skin = new Skin();
    }
    
    
    
    @Override
    public void render(float delta) {
        stage.act(delta);
        Gdx.gl.glClearColor( 0f, 0f, 0f, 1f );
        Gdx.gl.glClear( GL20.GL_COLOR_BUFFER_BIT );

        // draw the actors
        stage.draw();

        // draw the table debug lines
        
        
    }

    @Override
    public void resize(int width, int height) {
        
    }

    @Override
    public void show() {
        Gdx.input.setInputProcessor(stage);
    }

    @Override
    public void hide() {
    }

    @Override
    public void pause() {
    }

    @Override
    public void resume() {
    }

    @Override
    public void dispose() {
        font.dispose();
        batch.dispose();
    }

    protected boolean isGameScreen() {
        return false;
    }
}
